package com.lvhx.service;

import com.lvhx.dao.OrderMapper;
import com.lvhx.dao.extend.OrderExtednMapper;
import com.lvhx.pojo.Order;
import com.lvhx.pojo.OrderExample;
import com.lvhx.redis.MybatisRedisCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @auther 吕宏旭
 * @date 2019/8/24 13:54
 */
@Service
public class OrderService {

    @Autowired
    private OrderMapper orderMapper;

    @Autowired
    private OrderExtednMapper orderExtednMapper;

    public List<Order> findAllOreder() {
        List<Order> allInfo = orderExtednMapper.getAllInfo();
        return allInfo;
    }

    public void testInsert(Order order) {
        orderMapper.insertSelective(order);
    }

    public void updateOrder(Order order) {
//        orderExtednMapper.updateOrder(order.getId(),order.getName());
        orderMapper.updateByPrimaryKeySelective(order);
    }

    public Order findOrderById(String id) {
        return orderMapper.selectByPrimaryKey(id);
    }

    public void clearCache() {
        MybatisRedisCache mybatisRedisCache = new MybatisRedisCache();
        mybatisRedisCache.clearAll();
    }
}
